package p2;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2023-10-24
 * Time: 16:35
 */
public class exp3_2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int res = gcd(m, n);
        System.out.println(res);
    }

    private static int gcd(int m, int n) {
        if(n!=0){
            System.out.println("gcd "+ m +"," + n);
        }
        if(n==0) {
            return m;
        }
        return gcd(n, m%n);
    }
}
